
<!--当前登录-->
<link rel="stylesheet" href="{yun:}$style{/yun}/style/tck_logoin.css?v={yun:}$config.cachecode{/yun}" type="text/css"/>
<div class="none" id="onlogin">
  <div class="logoin_tck_left" style="margin-top: 25px;padding-left: 25px;">
<div style="position:absolute;right:14px;top;0;">
{yun:}if $config.wx_author=='1'{/yun}

<div class="wxcode_login" title="微信扫一扫登录" style="display:block;"></div>
<div class="normal_login none" title="普通登录"></div>
{yun:}/if{/yun}

</div>
<!---------------扫码登录页面---------------------->
<div class="wx_login_show none">
	 <div id="wx_login_qrcode" class="wxlogintext">正在获取二维码...</div>
	 <div class="wxlogintxt">请使用微信扫一扫登录</div>
</div>
<!------------------扫码登录页面end-->
  
  
  <div id="login_normal">
  <div class="logoin_tck_t_list"> 
    <div class="logoin_tck_tit">用户名：</div>
     <div class="logoin_tck_text" > 
      <i class="logoin_tck_text_icon"></i>
     <input type="text" id="login_username" placeholder="请输入用户名" tabindex="1" name="username" class="logoin_tck_text_t1" autocomplete="off"/>
    </div>
    </div>
            <div class="logoin_tck_t_list" >
    <div class="logoin_tck_tit">密&nbsp;&nbsp;&nbsp;&nbsp;码：</div>
    <div class="logoin_tck_text"> <i class="logoin_tck_text_icon logoin_tck_text_icon_p"></i>
      <input type="password" id="login_password" tabindex="2" name="password" placeholder="请输入密码" class="logoin_tck_text_t1" autocomplete="off"/>
    </div>
    </div>
    
	{yun:}if strpos($config.code_web,"前台登录")!==false{/yun}   
        {yun:}if $config.code_kind==3{/yun}	
	
		<script src="{yun:}$config.sy_weburl{/yun}/js/geetest/gt.js?v={yun:}$config.cachecode{/yun}"></script>
               <div class="logoin_tck_t_list" >
    <div class="logoin_tck_tit" style="line-height:42px;">验&nbsp;&nbsp;&nbsp;&nbsp;证：</div>    
     <div class="fastlogin_verification ">
		<div id="popup-captcha-publiclogin" data-id='sublogin' data-type='click'></div>
		<input type='hidden' id="popup-submit-publiclogin">
		<input type='hidden' name="geetest_challenge_publiclogin" value=''>
		<input type='hidden' name="geetest_validate_publiclogin" value=''>
		<input type='hidden' name="geetest_seccode_publiclogin" value=''>
</div></div>
    <style>
		.fastlogin_verification .geetest_holder.geetest_wind{min-width:200px;}
		</style>
		{yun:}else{/yun}   
                      <div class="logoin_tck_t_list" >
    <div class="logoin_tck_tit">验证码：</div>    
        <div class="logoin_tck_text logoin_tck_text_yzm"> <i class="logoin_tck_text_icon logoin_tck_text_icon_y"></i>
          <input id="login_authcode" type="text" tabindex="3"  maxlength="6" name="authcode" class="logoin_tck_text_t1" placeholder="请输入验证码"  style="width:80px;" autocomplete="off"/>
        </div>
        <div class=" logoin_tck_text_yzm_r"> <img id="vcode_img" src="{yun:}$config.sy_weburl{/yun}/app/include/authcode.inc.php" onclick="checkCode('vcode_img');" style="margin-right:5px; margin-left:5px;cursor:pointer;"/> 
        <input type="hidden" id="login_codekind" value="1" />
        </div>
        </div>
		{yun:}/if{/yun}
{yun:}else{/yun}
         <div class="logoin_tck_t_list" >
    <div class="logoin_tck_tit">&nbsp;</div>
    <a href="{yun:}url m=forgetpw{/yun}" class="logoin_tck_fw">忘记密码？</a>
    </div>

	<input type="hidden" id="login_codekind" value="0" />
	{yun:}/if{/yun}

   <div class="logoin_tck_t_list" >
    <div class="logoin_tck_tit">&nbsp;</div>
      <div id="msg"></div>
    
    <input type="hidden" id="login_usertype" />
    <input id="loginsubmit" class="logoin_tck_submit" type="button" name="loginsubmit" onclick="checkajaxlogin('vcode_img')" value="登录" ></div>
  </div>
   </div>
  <div class="logoin_tck_right" style="margin-top: 35px;padding-left: 20px;">
    <div class="logoin_tck_reg">还没有账号？<a href="" id="onregister" target="_blank" class="Orange">立即注册</a></div>
  </div>
</div>
<script>
function showlogin(usertype){
	$("#login_usertype").val(usertype);
	
	var reg_moblie = '{yun:}$config.reg_moblie{/yun}';
	var reg_email = '{yun:}$config.reg_email{/yun}';

	if(usertype==1 || usertype==""|| !usertype){
		
		if(reg_moblie == '1'){
			var url='{yun:}url m=register usertype=1 type=2{/yun}';
		}else if(reg_email == '1'){
			var url='{yun:}url m=register usertype=1 type=3{/yun}';
		}else{
			var url='{yun:}url m=register usertype=1 type=1{/yun}';
		}

 	}else if(usertype==2){

		if(reg_moblie == '1'){
			var url='{yun:}url m=register usertype=2 type=2{/yun}';
		}else if(reg_email == '1'){
			var url='{yun:}url m=register usertype=2 type=3{/yun}';
		}else{
			var url='{yun:}url m=register usertype=2 type=1{/yun}';
		}

	}else if(usertype==3){
		var url='{yun:}url m=lietou c=register{/yun}';
	}else if(usertype==4){
		var url='{yun:}url m=train c=register{/yun}';
	}
	$("#onregister").attr("href",url);
	$.layer({
		id : 'onloginid',
		type : 1,
		title :'快速登录', 
		closeBtn : [0 , true],
		offset:['20%','30%'],
		border : [10 , 0.3 , '#000', true],
		area : ['580px','300px'],
		page : {dom :"#onlogin"}
	});
}
function checkajaxlogin(img){
	var username = $.trim($("#login_username").val());
	var password = $.trim($("#login_password").val());
	var usertype = $.trim($("#login_usertype").val());
	var geetest_challenge;
	var geetest_validate;
	var geetest_seccode;
	var authcode;
	if(username == "" || password=="" ){
		layer.closeAll();
		layer.msg('请准确填写用户登录信息！', 2, 8,function(){showlogin(usertype);});return false;
	}
	var code_kind='{yun:}$config.code_kind{/yun}';
	var code_web='{yun:}$config.code_web{/yun}';
	var codesear=new RegExp('前台登录');
	if(codesear.test(code_web)){

		if(code_kind=='1'){
			authcode=$.trim($("#login_authcode").val());  
			if(authcode==''){
				layer.closeAll();
				layer.msg('请填写验证码！', 2, 8,function(){showlogin(usertype);});return false;
			}	
		}else if(code_kind=='3'){

			var geetest_challenge = $('input[name="geetest_challenge_publiclogin"]').val();
			var geetest_validate = $('input[name="geetest_validate_publiclogin"]').val();
			var geetest_seccode = $('input[name="geetest_seccode_publiclogin"]').val();
			if(geetest_challenge =='' || geetest_validate=='' || geetest_seccode==''){
				
				$("#popup-submit-publiclogin").trigger("click");
				layer.msg('请点击按钮进行验证！', 2, 8,function(){showlogin(usertype);});
				return false;
			}
		
		}
	}
	layer.load('登录中,请稍候...');

	$.post("{yun:}url m=login c=loginsave{/yun}",{comid:1,username:username,password:password,authcode:authcode,usertype:usertype,geetest_challenge:geetest_challenge,geetest_validate:geetest_validate,geetest_seccode:geetest_seccode},function(data){
		layer.closeAll(); 
		var jsonObject = eval("(" + data + ")"); 
		if(jsonObject.error == '3'){//UC登录激活 
			$('#uclogin').html(jsonObject.msg);
			setTimeout("window.location.href='"+jsonObject.url+"';",500); 
		}else if(jsonObject.error == '2'){//UC登录成功 
			$('#uclogin').html(jsonObject.msg); 
			setTimeout("location.reload();",500); 
		}else if(jsonObject.error == '1'){//正常登录成功 
			if ( $("#finderusertype").length > 0 ) {//如果存在则表示保存搜索器操作
				var finderusertype=$("#finderusertype").val();
				var finderparas=$("#finderparas").val();
				addfinder(finderparas,finderusertype,1);
			}else{
				location.reload();return false; 
			} 
		}else if(jsonObject.error == '0'){//登录失败或需要审核等提示 

			if(codesear.test(code_web)){
				if(code_kind=='1'){

		    	checkCode(img);

				}else if(code_kind=='3'){
				
					$("#popup-submit-publiclogin").trigger("click");
				
				}
			}
			layer.msg(jsonObject.msg, 2, 8,function(){showlogin(usertype);});
		   
		    return false;
			
		}
	});
}
$(document).ready(function(){


var handlerPopupLogin = function (captchaObj) {
	// 成功的回调
	
	captchaObj.onSuccess(function () {

		var validate = captchaObj.getValidate();
		
		if(validate){
			$("input[name='geetest_challenge_publiclogin']").val(validate.geetest_challenge);
			$("input[name='geetest_validate_publiclogin']").val(validate.geetest_validate);
			$("input[name='geetest_seccode_publiclogin']").val(validate.geetest_seccode);
		}

	});
	$("#popup-submit-publiclogin").click(function(){
		
		$("input[name='geetest_challenge_publiclogin']").val('');
		$("input[name='geetest_validate_publiclogin']").val('');
		$("input[name='geetest_seccode_publiclogin']").val('');
		
		captchaObj.reset();
	});
	
	captchaObj.appendTo("#popup-captcha-publiclogin");

};

if($("#popup-captcha-publiclogin").length>0){
	$.ajax({
			url: weburl+"/index.php?m=geetest&t=" + (new Date()).getTime(),
			type: "get",
			dataType: "json",
			success: function (data) {
			
				initGeetest({
					gt: data.gt,
					challenge: data.challenge,
					product: "popup",
					width:"100%",
					offline: !data.success,
					new_captcha: data.new_captcha
				}, handlerPopupLogin);
			}
	});
}
	var setval;
	$('.wxcode_login').click(function(data){
		
		$('.wxcode_login').hide();
		$('.normal_login').show();
		$('#login_normal').hide();
		$('.wx_login_show').show();
		$.post('{yun:}url m=login c=wxlogin{/yun}',{t:1},function(data){
			if(data==0){
				$('#wx_login_qrcode').html('二维码获取失败..');
			}else{
				$('#wx_login_qrcode').html('<img src="'+data+'" width="100" height="100">');
				setval = setInterval("wxorderstatus()", 2000); 
			}
		});

	});
	$('.normal_login').click(function(data){
	
		$('.wxcode_login').show();
		$('.normal_login').hide();
		$('#login_normal').show();
		$('.wx_login_show').hide();
		clearInterval(setval);
	});
});
function wxorderstatus() { 
	$.post('{yun:}url m=login c=getwxloginstatus{/yun}',{t:1},function(data){
		
		var data=eval('('+data+')');
		if(data.url!='' && data.msg!=''){
			layer.msg(data.msg, 2, 9,function(){window.location.href=data.url;});
		}else if(data.url){
			
			window.location.href='';
		}
	});
}
</script>